package com.fltry.mapdemo

import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.baidu.mapapi.map.*
import com.baidu.mapapi.model.LatLng
import java.util.ArrayList

/**
 *  Created on 2019-09-04 10:17
 *
 *  @author fengliang
 */
class MapFragment : Fragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        val view = layoutInflater.inflate(R.layout.map_fragment,container,false)
        val map = view.findViewById<MapView>(R.id.map)
        val map2 = view.findViewById<TextureMapView>(R.id.map2)
        val uiSettings = map.map.uiSettings
        uiSettings.isRotateGesturesEnabled = false//禁止地图旋转手势.
        map.map.setMapStatus(MapStatusUpdateFactory.zoomTo(12.0f))
        val abnormal = ArrayList<BitmapDescriptor>()
        abnormal.add(BitmapDescriptorFactory.fromResource(R.mipmap.cone_offline1))
        abnormal.add(BitmapDescriptorFactory.fromResource(R.mipmap.cone_offline2))
        val markerOption = MarkerOptions().anchor(0.5f, 0.5f)
            .position(LatLng(39.892825,116.422703)).draggable(true).period(50).icons(abnormal)
        map.map.addOverlay(markerOption)
        map2.map.addOverlay(markerOption)
        return view
    }

}